<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- vue js库-->
    <script src="./vue.js"></script>
</head>
<body>
<div id="example">
    <div id="demo">{{ fullName }}</div>

</div>

<script>

    /*将属性和 方法关联起来  属性改变会调用方法*/

    var vm = new Vue({
        el: '#demo',
        data: {
            firstName: 'Foo',
            lastName: 'Bar',
            fullName: 'Foo Bar'
        },
        watch: {
            firstName: function (val) {
                this.fullName = val + ' ' + this.lastName
            },
            lastName: function (val) {
                this.fullName = this.firstName + ' ' + val
            }
        }
    })


    setInterval(function (){
        vm.firstName=Date.now()
    },1000)

  //  vm.firstName='鲁大师'


</script>
</body>
</html>